<?php
session_start();
//require_once("../config/include.inc.php");
require_once("../config/include_tokyo.inc.php");
require_once("../class/Common_Function.php");

//访问权限验证
$userRole = $_SESSION['user_role'];
if($userRole == 1 || $userRole == 6 || $userRole == 8){
	//管理员,eub+团队成员
}else{
	if($userRole > 0){
		$url = "../index.php?loginError=2";//没权限
	}else{
		$url = "../index.php?loginError=3";//没登录
	}	
	echo "<script language='javascript' type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}


//更新快递单内容
$doFlag = $_POST["doFlag"];
if($doFlag == "updateOrder"){
	$orderId = $_POST["orderId"];
	$_GET['id'] = $orderId;
	$tracking_number = $_POST["tracking_number"];
	//$express_company = $_POST["express_company"];
	//$tracking_number_2 = $_POST["tracking_number_2"];
	//$express_company_2 = $_POST["express_company_2"];
	$sql = "update orders set tracking_number = '".$tracking_number."'";	
	//$sql = $sql.", express_company='".$express_company."'";
	//$sql = $sql.", tracking_number_2='".$tracking_number_2."'";
	//$sql = $sql.", express_company_2='".$express_company_2."'";
	$sql = $sql."  where id=".$orderId;
	$db->Execute($sql);
}


//快递单详情 
$id = $_GET['id'];
$sql = "SELECT * from orders where id=".$id;
$result = $db->Execute($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<? $pageTitle = "编辑快递单"; ?>
<?php include("../head.php"); ?>
<!--End:head-->


<body>
<?php include("../topMenu.php"); ?>


<form name="inputForm" action="../express/eubInput.php" method="post">
<div id="container" >	
<div class="grayTable">	
<h4>快递单详情:
<?php  if($doFlag == "updateOrder"){echo "快递单内容更新成功!";}?>
</h4>
<table >
<thead>
	<tr>
		<th scope="col" width=110>字段名称</th>
	    <th scope="col" >字段值</th>		
	</tr>
</thead>

<?php
$commonFunction = new Common_Function();

if(!$result->EOF){

	$strTR = "";
	$strTR = $strTR."<tr ><td>ID</td>";
	$strTR = $strTR."<td>".$result->fields['id']."</td></tr>";
	$strTR = $strTR."<tr ><td>网站名称</td>";
	$strTR = $strTR."<td>".$result->fields['order_site']."</td></tr>";
	$strTR = $strTR."<tr ><td>订单编号</td>";
	$strTR = $strTR."<td>".$result->fields['order_no']."</td></tr>";
	$strTR = $strTR."<tr ><td>电池状态</td>";
	$strTR = $strTR."<td>".$commonFunction->getBatteryStatusName($result->fields['battery_flag'])."</td></tr>";
	$strTR = $strTR."<tr ><td>创建时间</td>";
	$strTR = $strTR."<td>".$result->fields['create_time']."</td></tr>";
	$strTR = $strTR."<tr ><td>快递时间</td>";
	$strTR = $strTR."<td>".$result->fields['deliver_time']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户名字</td>";
	$strTR = $strTR."<td>".$result->fields['customer_name']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户电话</td>";
	$strTR = $strTR."<td>".$result->fields['customer_telephone']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户地址</td>";
	$strTR = $strTR."<td>".$result->fields['customer_address']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户邮编</td>";
	$strTR = $strTR."<td>".$result->fields['customer_postcode']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户备注</td>";
	$strTR = $strTR."<td>".$result->fields['customer_note']."</td></tr>";
	$strTR = $strTR."<tr ><td>客户Email</td>";
	$strTR = $strTR."<td>".$result->fields['customer_email']."</td></tr>";
	$strTR = $strTR."<tr ><td>产品描述</td>";
	$strTR = $strTR."<td>".$result->fields['product_description']."</td></tr>";
	$strTR = $strTR."<tr ><td>快递公司</td>";
	$strTR = $strTR."<td>";
	$strTR = $strTR."e邮宝";
	$strTR = $strTR."</td></tr>";
	$strTR = $strTR."<tr ><td>快递单号</td>";
	$strTR = $strTR."<td><input type='text' name='tracking_number' id='tracking_number' value='".$result->fields['tracking_number']."'></td></tr>";
	echo $strTR;
}
?>
<tr><td colspan=2 align=center>
<input type="button" value="保存" onclick="doUpdate('<?php echo $id;?>')">
<input type="button" value="返回" onClick="toList()">
</td></tr>
</table>



</div>

<br><br>

</div><!--end container -->

<input type="hidden" name="doFlag" id="doFlag" >
<input type="hidden" name="orderId" id="orderId" >
</form>
</body>




</html>

<script>
function doUpdate(id){
	document.getElementById('doFlag').value = 'updateOrder';
	document.getElementById('orderId').value = id;
	document.inputForm.submit();
}

function toList(){
	window.location.href = "eub.php";
}
</script>

